package org.wuyichun.gift.service.impl;

import org.springframework.beans.BeanUtils;
import org.wuyichun.gift.domain.Employee;
import org.wuyichun.gift.dto.EmployeeRegisterDto;
import org.wuyichun.gift.mapper.EmployeeMapper;
import org.wuyichun.gift.service.IEmployeeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.wuyichun.gift.util.AjaxResult;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wuyichun
 * @since 2024-10-07
 */
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements IEmployeeService {

    @Override
    public AjaxResult insert1(EmployeeRegisterDto employeeRegisterDto) {
        Employee emp = EmployeeRegisterDtoToEmployee(employeeRegisterDto);
        super.insert(emp);
        return AjaxResult.me().setSuccess(true).setResultObj(emp);
    }
    Employee EmployeeRegisterDtoToEmployee(EmployeeRegisterDto employeeRegisterDto){
        Employee employee = new Employee();
        BeanUtils.copyProperties(employeeRegisterDto,employee);
        employee.setInputTime(new Date());
        return employee;
    }
}
